#ifndef MYWIDGET_H
#define MYWIDGET_H

#include <QWidget>
#include <QEvent>
#include <QCloseEvent>

#define QDEBUG(MSG) qDebug() << (MSG)
#define CONSOLELOG(str,value) std::cout << str << value << std::endl;


class MyWidget : public QWidget
{
    Q_OBJECT
    // 属性声明
    // 使用Q_PROPERTY宏来声明属性，这样它们就可以在Qt的属性系统中使用
    // Q_INVOKABLE修饰过的函数可以使用 QMetaObject::invokeMethod 来调用
    Q_PROPERTY(int myProperty READ getMyProperty WRITE setMyProperty NOTIFY myPropertyChanged)
    Q_INVOKABLE void Meta_Fun();

public:
    explicit MyWidget(QWidget *parent = nullptr);
    int getMyProperty() const;
    void setMyProperty(int newMyProperty);

protected:
    void closeEvent(QCloseEvent *event) override;

public slots:
    // public slots 槽函数可以使用 QMetaObject::invokeMethod 来调用
    void Slot_Fun();

signals:
    void myPropertyChanged();
private:
    int m_myProperty;
};

#endif // MYWIDGET_H
